//--------------------------------------
// silk-editor-plugin Project
//
// SilkColor.java
// Since: 2010/11/15
//
// $URL$ 
// $Author$
//--------------------------------------
package org.xerial.silk.editor.plugin.text;

import org.eclipse.swt.graphics.RGB;

public enum SilkColor {

    Default("Default Texts", 0, 0, 0),
    Comment("Line Comments", 128, 0, 0),
    NodeName("Node Names", "#3399CC"),
    NodeValue("Node Values", 0, 0, 0),
    AttributeName("Attribute Names", 64, 0, 128),
    AttributeValue("Attribute Values", 64, 128, 64),
    Function("Functions", "#9933CC"),
    Preamble("Preambles", 128, 0, 128),
    TypeName("Type Names", 0, 128, 9),
    Operator("Operators", 64, 64, 64),
    String("Strings", "#FFCC99"),
    Number("Numbers", "#FF9966");

    public final String fieldName;
    public final RGB    defaultColor;
    public final String key;

    private SilkColor(String fieldName, int r, int g, int b) {
        this(fieldName, new RGB(r, g, b));
    }

    private SilkColor(String fieldName, String rgb) {
        this(fieldName, toRGB(rgb));
    }

    private SilkColor(String fieldName, RGB rgb) {
        this.fieldName = fieldName;
        this.defaultColor = rgb;
        this.key = "SILK_" + this.name();
    }

    private static RGB toRGB(String rgb) {
        int r = Integer.parseInt(rgb.substring(1, 3), 16);
        int g = Integer.parseInt(rgb.substring(3, 5), 16);
        int b = Integer.parseInt(rgb.substring(5, 7), 16);
        return new RGB(r, g, b);
    }

}
